<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Slider 滑动选择器 | WUU-UI</title>
    <meta name="generator" content="VuePress 1.8.2">
    
    <meta name="description" content="WUU-UI">
    
    <link rel="preload" href="/mall-ui/assets/css/0.styles.fb3964a0.css" as="style"><link rel="preload" href="/mall-ui/assets/js/app.71961e7f.js" as="script"><link rel="preload" href="/mall-ui/assets/js/2.f1cb9681.js" as="script"><link rel="preload" href="/mall-ui/assets/js/10.11912e0a.js" as="script"><link rel="prefetch" href="/mall-ui/assets/js/11.bca6f591.js"><link rel="prefetch" href="/mall-ui/assets/js/12.b3358f86.js"><link rel="prefetch" href="/mall-ui/assets/js/13.06b07c8e.js"><link rel="prefetch" href="/mall-ui/assets/js/3.4e208c7e.js"><link rel="prefetch" href="/mall-ui/assets/js/4.110a989f.js"><link rel="prefetch" href="/mall-ui/assets/js/5.c89a64a3.js"><link rel="prefetch" href="/mall-ui/assets/js/6.83fdb325.js"><link rel="prefetch" href="/mall-ui/assets/js/7.be3d3bc1.js"><link rel="prefetch" href="/mall-ui/assets/js/8.48f4c41d.js"><link rel="prefetch" href="/mall-ui/assets/js/9.1c35ec6b.js">
    <link rel="stylesheet" href="/mall-ui/assets/css/0.styles.fb3964a0.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/mall-ui/" class="home-link router-link-active"><img src="/mall-ui/images/wuu.png" alt="WUU-UI" class="logo"> <span class="site-name can-hide">WUU-UI</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/mall-ui/comps/configure/introduce.html" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/mall-ui/comps/assembly/slider.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  组件
</a></div><div class="nav-item"><a href="/mall-ui/comps/readme/wxsc.html" class="nav-link">
  JS
</a></div><div class="nav-item"><a href="/mall-ui/comps/about/index.html" class="nav-link">
  关于我们
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/mall-ui/comps/configure/introduce.html" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/mall-ui/comps/assembly/slider.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  组件
</a></div><div class="nav-item"><a href="/mall-ui/comps/readme/wxsc.html" class="nav-link">
  JS
</a></div><div class="nav-item"><a href="/mall-ui/comps/about/index.html" class="nav-link">
  关于我们
</a></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/mall-ui/comps/assembly/slider.html" aria-current="page" class="active sidebar-link">Slider 滑动选择器</a></li><li><a href="/mall-ui/comps/assembly/button.html" class="sidebar-link">Button 按钮</a></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="slider-滑动选择器"><a href="#slider-滑动选择器" class="header-anchor">#</a> Slider 滑动选择器</h1> <p>该组件一般用于表单中，手动选择一个区间范围的场景。
<br> <br></p> <p><font size="5"> 平台差异说明 </font> <br></p> <table><thead><tr><th style="text-align:center;">App</th> <th style="text-align:center;">H5</th> <th style="text-align:center;">微信小程序</th> <th style="text-align:center;">支付宝小程序</th> <th style="text-align:center;">百度小程序</th> <th style="text-align:center;">头条小程序</th> <th style="text-align:center;">QQ小程序</th></tr></thead> <tbody><tr><td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td> <td style="text-align:center;">✔️</td></tr></tbody></table> <br> <p><font size="5"> 基本使用 </font></p> <p><font size="2" color="#5e6d82"> 需要通过v-model绑定一个值，来初始化滑块的选择值(0到100之间)，这个值是双向绑定的，您可以通过这个值，实时地得知内部的滑动结果。</font></p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>view</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>wrap<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mall-slider</span> <span class="token attr-name">v-model</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>percent<span class="token punctuation">&quot;</span></span> <span class="token attr-name">@move</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>move<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mall-slider</span><span class="token punctuation">&gt;</span></span>
 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>view</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
 <span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  <span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token operator">|</span>
   <span class="token keyword">return</span> <span class="token punctuation">{</span>
    percent<span class="token operator">:</span><span class="token number">20</span>
   <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function">methods</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token function">move</span> <span class="token punctuation">(</span><span class="token parameter">value</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
 <span class="token punctuation">}</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span> <span class="token attr-name">scoped</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>scss<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token style"><span class="token language-css">
 <span class="token selector">.wrap</span> <span class="token punctuation">{</span>
  <span class="token property">padding</span><span class="token punctuation">:</span> 30rpx<span class="token punctuation">;</span>
 <span class="token punctuation">}</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><br> <p><font size="5"> 设置最大和最小值 </font></p> <p><font size="2" color="#5e6d82"> 通过<kbd>min</kbd>和<kbd>max</kbd>，可以设置滑块所能选择的最大和最小值 </font></p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mall-slider</span> <span class="token attr-name">v-model</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>percent<span class="token punctuation">&quot;</span></span> <span class="token attr-name">min</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>10<span class="token punctuation">&quot;</span></span> <span class="token attr-name">max</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mall-slider</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><p><font size="5">设置步进值</font></p> <p><font size="2" color="#5e6d82">通过<kbd>step</kbd>参数设置步进值，这个步进值为每次跳变的值。</font></p> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p><font size="3" color="#5e6d82">需要注意的是，这个step必须要被max值整除，否则会出现无法无法滑动到最大值的情况</font></p></div> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mall-slider</span> <span class="token attr-name">v-model</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>percent<span class="token punctuation">&quot;</span></span> <span class="token attr-name">min</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>10<span class="token punctuation">&quot;</span></span> <span class="token attr-name">max</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>50<span class="token punctuation">&quot;</span></span> <span class="token attr-name">step</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>5<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mall-slider</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><br> <p><font size="5">自定义滑动选择器整体的样式</font><br><br> <font size="2" color="#5e6d82">
    通过<kbd>inactiveColor</kbd>配置底部滑动条背景颜色<br>
    通过<kbd>activeColor</kbd>配置底部选择部分的背景颜色<br>
    通过<kbd>blockWidth</kbd>配置滑块宽度(高等于宽)<br>
    通过<kbd>blockColor</kbd>配置滑动按钮按钮的颜色<br>
    通过<kbd>height</kbd>配置滑块条高度，单位rpx </font></p> <p><font size="2" color="#5e6d82">其他更多参数详见底部API</font></p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mall-slider</span> <span class="token attr-name">v-model</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>percent<span class="token punctuation">&quot;</span></span> <span class="token attr-name">blockWidth</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>40<span class="token punctuation">&quot;</span></span> <span class="token attr-name">blockColor</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>red<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mall-slider</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><br> <p><font size="5">API</font> <br></p> <p><font size="5">Props</font></p> <table><thead><tr><th style="text-align:left;">参数</th> <th style="text-align:left;">说明</th> <th style="text-align:left;">类型</th> <th style="text-align:left;">默认值</th> <th style="text-align:left;">可选值</th></tr></thead> <tbody><tr><td style="text-align:left;">v-model</td> <td style="text-align:left;">双向绑定滑块选择值</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">0</td></tr> <tr><td style="text-align:left;">min</td> <td style="text-align:left;">可选的最小值(0-100之间)</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">0</td></tr> <tr><td style="text-align:left;">max</td> <td style="text-align:left;">可选的最大值(0-100之间)</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">100</td></tr> <tr><td style="text-align:left;">step</td> <td style="text-align:left;">选择的步长</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">1</td></tr> <tr><td style="text-align:left;">blockWidth</td> <td style="text-align:left;">滑动按钮的宽度(高等于宽)，单位rpx</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">30</td></tr> <tr><td style="text-align:left;">height</td> <td style="text-align:left;">滑动选择条的高度，单位rpx</td> <td style="text-align:left;">String</td> <td style="text-align:left;">Number</td> <td style="text-align:left;">6</td></tr> <tr><td style="text-align:left;">inactiveColor</td> <td style="text-align:left;">滑动选择条的底部背景颜色</td> <td style="text-align:left;">String</td> <td style="text-align:left;">#c0c4cc</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">activeColor</td> <td style="text-align:left;">底部选择部分的背景颜色</td> <td style="text-align:left;">String</td> <td style="text-align:left;">#2979ff</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">blockColor</td> <td style="text-align:left;">滑块背景颜色</td> <td style="text-align:left;">String</td> <td style="text-align:left;">#ffffff</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">blockStyle</td> <td style="text-align:left;">给滑块按钮自定义样式，对象形式</td> <td style="text-align:left;">Object</td> <td style="text-align:left;">-</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">disabled</td> <td style="text-align:left;">是否禁用滑块</td> <td style="text-align:left;">Boolean</td> <td style="text-align:left;">false</td> <td style="text-align:left;">true</td></tr> <tr><td style="text-align:left;">shapeType</td> <td style="text-align:left;">滑块形状</td> <td style="text-align:left;">String</td> <td style="text-align:left;">circular</td> <td style="text-align:left;">-</td></tr></tbody></table> <p><font size="5">Events</font></p> <table><thead><tr><th style="text-align:left;">事件名</th> <th style="text-align:left;">说明</th> <th style="text-align:left;">回调参数</th></tr></thead> <tbody><tr><td style="text-align:left;">start</td> <td style="text-align:left;">触发滑块移动</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">moving</td> <td style="text-align:left;">正在滑动中</td> <td style="text-align:left;">-</td></tr> <tr><td style="text-align:left;">end</td> <td style="text-align:left;">滑动结束</td> <td style="text-align:left;">-</td></tr></tbody></table> <div class="demo-model"><div class="model-content"><iframe data-v-16de2a8a="" scrolling="auto" frameborder="0" src="https://h5.uviewui.com/#/pages/componentsA/slider/index" id="demo-modal" class="iframe"></iframe></div></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/mall-ui/comps/assembly/button.html">
        Button 按钮
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/mall-ui/assets/js/app.71961e7f.js" defer></script><script src="/mall-ui/assets/js/2.f1cb9681.js" defer></script><script src="/mall-ui/assets/js/10.11912e0a.js" defer></script>
  </body>
</html>
